package com.haulmont.asu.web.ui.theme_booking_command_template;

import com.haulmont.asu.entity.ThemeBookingCommand;
import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.components.AbstractEditor;
import com.haulmont.cuba.gui.components.Action;
import com.haulmont.cuba.gui.components.Table;
import com.haulmont.cuba.gui.components.actions.CreateAction;

import javax.inject.Inject;
import java.util.Map;

/**
 * Author: Sergey42
 * Date: 17.11.13 21:46
 */
public class ThemeBookingCommandTemplateEditor extends AbstractEditor<ThemeBookingCommand> {

    @Inject
    protected Table bookingTable;

    @Override
    public void init(Map<String, Object> params) {
        Action createAction = bookingTable.getAction("create");
        bookingTable.removeAction(createAction);

        bookingTable.addAction(new CreateAction(bookingTable, WindowManager.OpenType.DIALOG));
    }

    @Override
    protected void initItem(ThemeBookingCommand item) {
        item.setTemplate(true);
    }
}
